package com.wb.mianxiangduixiang.bms;

/**
 * @author 黄衡熙
 * @version 1.0
 * @date 2025年07月22日14:03
 */
//账户类,抽象类abstract
public abstract class Account {
    private static int currentId = 1000;
    // 卡号。自动生成,初始值1000,每次新开户的卡号自增1,例如:1001、1002、1003...
    private int id;
    private String name;
    private String password;
    private String personId;
    private String phone;
    private double balance;

    public Account() {
        this.id=currentId++;
        // 由于卡号是自动生成的,因此在创建对象的时候自动生成对应的卡号
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPersonId() {
        return personId;
    }

    public void setPersonId(String personId) {
        this.personId = personId;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    /**
     * 存款方法,不允许子类修改
     * 因此,此处方法使用final修饰,不允许子类重写
     * @param money 存款的金额
     */
    public final void deposit(double money) {
        if (money > 0) {
            this.balance += money;
            System.out.println("存款成功！当前余额为：" + this.balance);
        } else {
            System.out.println("存款金额必须大于0！");
        }
        // 实现存款功能
        /*Account account = Bank.login(id, password);
        new BankMenu(account).showMenu();*/
    }

    /**
     * 取款,子类根据业务需求进行重写,必须重写
     * 因此,此处方法是一个抽象方法
     * @param money 取款金额
     * @return 取款是否成功
     */
    public abstract boolean withdrawMoney(double money);
    public abstract boolean transferMoney(double money, Account account1);
}

